import axios from 'axios'
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
import store from '@/store';
import user from '@/utils/userabout'
const service = axios.create({
    //配置基础路径和超时限制
    baseURL: '/api', //基础路径
    timeout: 20000, //超时时间
});
service.interceptors.request.use((config) => {
    Nprogress.start()
    let userTempId =store.state.user.userTempId
    //  store.state.user.userTempId
    if(userTempId){
      config.headers.userTempId=userTempId
    }
    return config
})
service.interceptors.response.use(
    (response) => {
      Nprogress.done()
      return response.data
    },
    (error) => {
      Nprogress.done()
  
      alert('发送ajax请求失败' + error.message || '未知错误' )
      return new Promise(() => {}) 
    }
  );
  export default service
